﻿using System;
using AMM.Model;
using AMM.Model.Business;

namespace AMM.UserControls {
    public partial class CustomerSearchControl : BaseSearchControl {

        public override BaseSearchModel GetSearchModel() {
            int enabledValue = Convert.ToInt32(this.cmbIsEnabled.SelectedValue);

            CustomerSearchModel searchResult = new CustomerSearchModel();
            searchResult.Code = this.tbCode.Text;
            searchResult.Name = this.tbName.Text;
            searchResult.Address = this.tbAddress.Text;
            searchResult.IsEnabled = Convert.ToBoolean(enabledValue);

            if (enabledValue == -1) { searchResult.IsEnabled = null; }

            return searchResult;
        }

        public override void ResetSearchModel() {
            this.tbCode.Clear();
            this.tbName.Clear();
            this.tbAddress.Clear();
            this.cmbIsEnabled.SelectedValue = "-1";
        }

        public CustomerSearchControl() {
            this.InitializeComponent();

            this.BindIsEnabled(this.cmbIsEnabled);
        }
    }
}
